#### Covid-19 Spillover Effects onto General Vaccine Attitudes
### Replication code - experiment in supplement 
### use file "experimentw23.txt"
### Kristin Lunz Trujillo



library(plyr)
library(dplyr)
library(haven)
library(srvyr)
library(survey)
library(tidyr)
library(broom)
library(purrr)
library(ggplot2)
library(stargazer)
library(dotwhisker)
library(tibble)
library(xtable)
library(ltm)
library(jtools)
library(MASS)
library(ggpubr)

w23 <- read.csv(".../experimentw23.csv")



### Data cleaning

w23 <- w23 %>% 
  mutate(
    exp = case_when(
      exp_cond_1 == 7 ~ 0,
      exp_cond_1 == 1 ~ 1,
      exp_cond_1 == 2 ~ 2,
      exp_cond_1 == 3 ~ 3,
      exp_cond_1 == 4 ~ 4,
      exp_cond_1 == 5 ~ 5,
      exp_cond_1 == 6 ~ 6))
table(w23$exp)
w23 <- w23 %>%
  mutate(
    exp_bi = case_when(
      exp == 0 ~ 0,
      exp == 1 ~1,
      exp==2~1,
      exp==3~1,
      exp==4~1,
      exp==5~1,
      exp==6~1
    ),
    Condition1 = case_when(
      exp_cond_1 == 1 ~ 1,
      exp_cond_1 != 1 ~ 0),
    Condition2 = case_when(
      exp_cond_1 == 2 ~ 1,
      exp_cond_1 != 2 ~ 0),
    Condition3 = case_when(
      exp_cond_1 == 3 ~ 1,
      exp_cond_1 != 3 ~ 0),
    Condition4 = case_when(
      exp_cond_1 == 4 ~ 1,
      exp_cond_1 != 4 ~ 0),
    Condition5 = case_when(
      exp_cond_1 == 5 ~ 1,
      exp_cond_1 !=1 ~ 0),
    Condition6 = case_when(
      exp_cond_1 == 6 ~ 1,
      exp_cond_1 != 6 ~ 0),
    Control = case_when(
      exp_cond_1 == 7 ~ 1,
      exp_cond_1 != 7 ~ 0),
    cov_risk_bi = case_when(
      cov_risk > 2 ~ 0,
      cov_risk == 2 ~ 1,
      cov_risk == 1 ~ 1),
    mmr_risk_bi = case_when(
      mmr_risk > 2 ~ 0,
      mmr_risk == 2 ~ 1,
      mmr_risk == 1 ~ 1),
    wording = case_when(
      exp_cond_2 == "mandates" ~ 0,
      exp_cond_2 == "requirements" ~ 1),
    novaccine = case_when(
      vaccine_get == 3 ~ 1,
      vaccine_get != 3 ~ 0
    )
    
  )
w23 <- w23 %>% 
  mutate(
    cov_risk2 = (-cov_risk + 4),
    mmr_risk2 = (-mmr_risk + 4)
  )

w23$insttrust = (w23$inst_trust1_7+w23$inst_trust1_9+w23$inst_trust2_2+w23$inst_trust2_3)
table(w23$insttrust)

w23 <- w23 %>%
  mutate(
    insttrust_step = case_when(insttrust == 16 ~ "A. High Trust",
                               insttrust == 15 ~ "A. High Trust",
                               insttrust == 14 ~ "A. High Trust",
                               insttrust == 13 ~ "B. Medium-High Trust",
                               insttrust == 12 ~ "B. Medium-High Trust",
                               insttrust == 11 ~ "B. Medium-High Trust",
                               insttrust == 10 ~ "C. Medium-Low Trust",
                               insttrust == 9 ~ "C. Medium-Low Trust",
                               insttrust == 8 ~ "C. Medium-Low Trust",
                               insttrust == 7 ~ "D. Low Trust",
                               insttrust == 6 ~ "D. Low Trust",
                               insttrust == 5 ~ "D. Low Trust",
                               insttrust == 4 ~ "D. Low Trust"))


w23$cov_risk2 <- as.factor(w23$cov_risk2)
w23$mmr_risk2 <- as.factor(w23$mmr_risk2)




# data split by second condition
mandat <- w23 %>% filter(exp_cond_2 == "mandates")
mandat
reqdat <- w23 %>% filter(exp_cond_2 == "requirements")
reqdat






################################################################################
### By mandates v requirements - Figure S1 ####################################
lm2m <- lm(cov_mand ~ factor(exp), data = mandat)
summary(lm2m)
lm4m <- lm(mmr_mand ~ factor(exp), data = mandat)
summary(lm4m)
lm5m <- glm(formula = cov_risk_bi ~ factor(exp), family = binomial(link = "logit"), 
            data = mandat)
summary(lm5m)
lm6m <- glm(formula = mmr_risk_bi ~ factor(exp), family = binomial(link = "logit"), 
            data = mandat)
summary(lm6m)

lm2r <- lm(cov_mand ~ factor(exp), data = reqdat)
summary(lm2r)
lm4r <- lm(mmr_mand ~ factor(exp), data = reqdat)
summary(lm4r)
lm5r <- glm(formula = cov_risk_bi ~ factor(exp), family = binomial(link = "logit"), 
            data = reqdat)
summary(lm5r)
lm6r <- glm(formula = mmr_risk_bi ~ factor(exp), family = binomial(link = "logit"), 
            data = reqdat)
summary(lm6r)



figure2xmand <- dwplot(list(lm5m, lm2m, lm6m, lm4m),
                       dot_args = list(size = 2),
                       whisker_args=list(size=.7),
                       vline = geom_vline(
                         xintercept = 0,
                         colour = "grey60",
                         linetype = 2),
                       vars_order = c("factor(exp)1", "factor(exp)2", "factor(exp)3", "factor(exp)4", "factor(exp)5", "factor(exp)6")) %>% 
  relabel_predictors(
    c("factor(exp)1" = "Freedoms Condition",
      "factor(exp)2" = "Too New Condition",
      "factor(exp)3" = "Trust Condition",
      "factor(exp)4" = "Moral Condition",
      "factor(exp)5" = "Pandemic Condition",
      "factor(exp)6" = "Partisanship Condition")) +
  theme_bw(base_size = 16) + xlab("Coefficient Estimate") + ylab("") + xlab("") + 
  ggtitle("") +
  scale_colour_grey(
    name = "Outcomes",
    labels = c("Covid Vaccine", "Covid Mandate", "Childhood Vaccine", "Childhood Mandate")) + theme(legend.title=element_text(size=11), legend.position = c(0.85,0.25), legend.text=element_text(size=9), 
                                                                                                    legend.background=element_rect(linetype="solid", colour="#999999")) + 
  scale_x_continuous(limits = c(-1, 1)) 
figure2xmand

figure2xreq <- dwplot(list(lm5r, lm2r, lm6r, lm4r),
                      dot_args = list(size = 2),
                      whisker_args=list(size=.7),
                      vline = geom_vline(
                        xintercept = 0,
                        colour = "grey60",
                        linetype = 2),
                      vars_order = c("factor(exp)1", "factor(exp)2", "factor(exp)3", "factor(exp)4", "factor(exp)5", "factor(exp)6")) %>% 
  relabel_predictors(
    c("factor(exp)1" = "Freedoms Condition",
      "factor(exp)2" = "Too New Condition",
      "factor(exp)3" = "Trust Condition",
      "factor(exp)4" = "Moral Condition",
      "factor(exp)5" = "Pandemic Condition",
      "factor(exp)6" = "Partisanship Condition")) +
  theme(legend.position = "bottom") + 
  theme_bw(base_size = 16) + xlab("Coefficient Estimate") + ylab("") + xlab("") +
  ggtitle("") +
  scale_colour_grey(
    name = "Outcomes",
    labels = c("Covid Vaccine", "Covid Mandate", "Childhood Vaccine", "Childhood Mandate")) + theme(legend.title=element_text(size=11), legend.position = c(0.85,0.25), legend.text=element_text(size=9), 
                                                                                                    legend.background=element_rect(linetype="solid", colour="#999999")) + 
  scale_x_continuous(limits = c(-1, 1)) 
figure2xreq

figure2 <- ggarrange(figure2xmand, figure2xreq, ncol=1, nrow=2, labels=c('Mandates', 'Requirements'))
figure2
################################################################################




################################################################################
##### By Dems/Reps ###################### Figures S2-S4 #########################

# data split
demdat <- w23 %>% filter(party7 > 4)
demdat
repdat <- w23 %>% filter(party7 < 4)
repdat
demdatman <- demdat %>% filter(exp_cond_2 == "mandates")
demdatman
repdatman <- repdat %>% filter(exp_cond_2 == "mandates")
repdatman
inddat <- w23 %>% filter(party7==4)
inddat
inddatman <- inddat %>% filter(exp_cond_2=="mandates")



### Mandates by party
lm2d <- lm(cov_mand ~ factor(exp), data = demdatman)
summary(lm2d)
lm4d <- lm(mmr_mand ~ factor(exp), data = demdatman)
summary(lm4d)
lm5d <- polr(factor(cov_risk2) ~ factor(exp), data = demdatman, Hess=TRUE)
summary(lm5d)
lm6d <- polr(factor(mmr_risk2) ~ factor(exp), data = demdatman, Hess=TRUE)
summary(lm6d)
figure3dxz <- dwplot(list(lm5d, lm2d, lm6d, lm4d),
                     vline = geom_vline(
                       xintercept = 0,
                       colour = "grey60",
                       linetype = 2),
                     vars_order = c("factor(exp)1", "factor(exp)2", "factor(exp)3", "factor(exp)4", "factor(exp)5", "factor(exp)6")) %>% 
  relabel_predictors(
    c("factor(exp)1" = "Freedoms Condition",
      "factor(exp)2" = "Too New Condition",
      "factor(exp)3" = "Trust Condition",
      "factor(exp)4" = "Moral Condition",
      "factor(exp)5" = "Pandemic Condition",
      "factor(exp)6" = "Partisanship Condition")) + 
  theme(legend.position = "bottom") + scale_x_continuous(limits = c(-1, 1)) + 
  theme_bw(base_size = 18) + xlab("") + ylab("") +
  ggtitle("Democrats ('Mandates' Only)") +
  scale_colour_grey(
    name = "Outcomes",
    labels = c("Covid Vaccine", "Covid Mandate", "Childhood Vaccine", "Childhood Mandate")) + theme(legend.title=element_text(size=13), legend.position = c(0.15,0.15), legend.text=element_text(size=11), 
                                                                                                    legend.background=element_rect(linetype="solid", colour="#999999")) 
figure3dxz

lm2r <- lm(cov_mand ~ factor(exp), data = repdatman)
summary(lm2r)
lm4r <- lm(mmr_mand ~ factor(exp), data = repdatman)
summary(lm4r)
lm5r <- polr(factor(cov_risk2) ~ factor(exp), data = repdatman, Hess=TRUE)
summary(lm5r)
lm6r <- polr(factor(mmr_risk2) ~ factor(exp), data = repdatman, Hess=TRUE)
summary(lm6r)
figure3rxz <- dwplot(list(lm5r, lm2r, lm6r, lm4r),
                     vline = geom_vline(
                       xintercept = 0,
                       colour = "grey60",
                       linetype = 2),
                     vars_order = c("factor(exp)1", "factor(exp)2", "factor(exp)3", "factor(exp)4", "factor(exp)5", "factor(exp)6")) %>% 
  relabel_predictors(
    c("factor(exp)1" = "Freedoms Condition",
      "factor(exp)2" = "Too New Condition",
      "factor(exp)3" = "Trust Condition",
      "factor(exp)4" = "Moral Condition",
      "factor(exp)5" = "Pandemic Condition",
      "factor(exp)6" = "Partisanship Condition")) + 
  theme(legend.position = "bottom") + 
  theme_bw(base_size = 18) + xlab("") + ylab("") +
  ggtitle("Republicans ('Mandates' Only)") + scale_x_continuous(limits = c(-1, 1)) +
  scale_colour_grey(
    name = "Outcomes",
    labels = c("Covid Vaccine", "Covid Mandate", "Childhood Vaccine", "Childhood Mandate")) + theme(legend.title=element_text(size=13), legend.position = c(0.85,0.15), legend.text=element_text(size=11), 
                                                                                                    legend.background=element_rect(linetype="solid", colour="#999999")) 
figure3rxz

lm2iman <- lm(cov_mand ~ factor(exp), data = inddatman)
summary(lm2iman)
lm4iman <- lm(mmr_mand ~ factor(exp), data = inddatman)
summary(lm4iman)
lm5iman <- polr(cov_risk2 ~ factor(exp), data = inddatman, Hess=TRUE)
summary(lm5iman)
lm6iman <- polr(mmr_risk2 ~ factor(exp), data = inddatman, Hess=TRUE)
summary(lm6iman)
figure3ixz <- dwplot(list(lm5iman, lm2iman, lm6iman, lm4iman),
                     vline = geom_vline(
                       xintercept = 0,
                       colour = "grey60",
                       linetype = 2),
                     vars_order = c("factor(exp)1", "factor(exp)2", "factor(exp)3", "factor(exp)4", "factor(exp)5", "factor(exp)6")) %>% 
  relabel_predictors(
    c("factor(exp)1" = "Freedoms Condition",
      "factor(exp)2" = "Too New Condition",
      "factor(exp)3" = "Trust Condition",
      "factor(exp)4" = "Moral Condition",
      "factor(exp)5" = "Pandemic Condition",
      "factor(exp)6" = "Partisanship Condition")) + 
  theme(legend.position = "bottom") + 
  theme_bw(base_size = 18) + xlab("") + ylab("") +
  ggtitle("Independents ('Mandates' Only)") + scale_x_continuous(limits = c(-1, 1)) +
  scale_colour_grey(
    name = "Outcomes",
    labels = c("Covid Vaccine", "Covid Mandate", "Childhood Vaccine", "Childhood Mandate")) + theme(legend.title=element_text(size=13), legend.position = c(0.15,0.15), legend.text=element_text(size=11), 
                                                                                                    legend.background=element_rect(linetype="solid", colour="#999999")) 
figure3ixz




## Requirements by partisanship
demdatreq <- demdat %>% filter(exp_cond_2 == "requirements")
repdatreq <- repdat %>% filter(exp_cond_2 == "requirements")
inddatreq <- inddat %>% filter(exp_cond_2=="requirements")

lm2d <- lm(cov_mand ~ factor(exp), data = demdatreq)
summary(lm2d)
lm4d <- lm(mmr_mand ~ factor(exp), data = demdatreq)
summary(lm4d)
lm5d <- polr(factor(cov_risk2) ~ factor(exp), data = demdatreq, Hess=TRUE)
summary(lm5d)
lm6d <- polr(factor(mmr_risk2) ~ factor(exp), data = demdatreq, Hess=TRUE)
summary(lm6d)
figure3dxr <- dwplot(list(lm5d, lm2d, lm6d, lm4d),
                     vline = geom_vline(
                       xintercept = 0,
                       colour = "grey60",
                       linetype = 2),
                     vars_order = c("factor(exp)1", "factor(exp)2", "factor(exp)3", "factor(exp)4", "factor(exp)5", "factor(exp)6")) %>% 
  relabel_predictors(
    c("factor(exp)1" = "Freedoms Condition",
      "factor(exp)2" = "Too New Condition",
      "factor(exp)3" = "Trust Condition",
      "factor(exp)4" = "Moral Condition",
      "factor(exp)5" = "Pandemic Condition",
      "factor(exp)6" = "Partisanship Condition")) + 
  theme(legend.position = "bottom") + scale_x_continuous(limits = c(-1, 1)) + 
  theme_bw(base_size = 18) + xlab("") + ylab("") +
  ggtitle("Democrats ('Requirements' Only)") +
  scale_colour_grey(
    name = "Outcomes",
    labels = c("Covid Vaccine", "Covid Mandate", "Childhood Vaccine", "Childhood Mandate")) + theme(legend.title=element_text(size=13), legend.position = c(0.15,0.15), legend.text=element_text(size=11), 
                                                                                                    legend.background=element_rect(linetype="solid", colour="#999999")) 
figure3dxr

lm2r <- lm(cov_mand ~ factor(exp), data = repdatreq)
summary(lm2r)
lm4r <- lm(mmr_mand ~ factor(exp), data = repdatreq)
summary(lm4r)
lm5r <- polr(factor(cov_risk2) ~ factor(exp), data = repdatreq, Hess=TRUE)
summary(lm5r)
lm6r <- polr(factor(mmr_risk2) ~ factor(exp), data = repdatreq, Hess=TRUE)
summary(lm6r)
figure3rxr <- dwplot(list(lm5r, lm2r, lm6r, lm4r),
                     vline = geom_vline(
                       xintercept = 0,
                       colour = "grey60",
                       linetype = 2),
                     vars_order = c("factor(exp)1", "factor(exp)2", "factor(exp)3", "factor(exp)4", "factor(exp)5", "factor(exp)6")) %>% 
  relabel_predictors(
    c("factor(exp)1" = "Freedoms Condition",
      "factor(exp)2" = "Too New Condition",
      "factor(exp)3" = "Trust Condition",
      "factor(exp)4" = "Moral Condition",
      "factor(exp)5" = "Pandemic Condition",
      "factor(exp)6" = "Partisanship Condition")) + 
  theme(legend.position = "bottom") + 
  theme_bw(base_size = 18) + xlab("") + ylab("") +
  ggtitle("Republicans ('Requirements' Only)") + scale_x_continuous(limits = c(-1, 1)) +
  scale_colour_grey(
    name = "Outcomes",
    labels = c("Covid Vaccine", "Covid Mandate", "Childhood Vaccine", "Childhood Mandate")) + theme(legend.title=element_text(size=13), legend.position = c(0.85,0.15), legend.text=element_text(size=11),                                                                                       legend.background=element_rect(linetype="solid", colour="#999999")) 
figure3rxr

lm2iman <- lm(cov_mand ~ factor(exp), data = inddatreq)
summary(lm2iman)
lm4iman <- lm(mmr_mand ~ factor(exp), data = inddatreq)
summary(lm4iman)
lm5iman <- polr(cov_risk2 ~ factor(exp), data = inddatreq, Hess=TRUE)
summary(lm5iman)
lm6iman <- polr(mmr_risk2 ~ factor(exp), data = inddatreq, Hess=TRUE)
summary(lm6iman)
figure3ixr <- dwplot(list(lm5iman, lm2iman, lm6iman, lm4iman),
                     vline = geom_vline(
                       xintercept = 0,
                       colour = "grey60",
                       linetype = 2),
                     vars_order = c("factor(exp)1", "factor(exp)2", "factor(exp)3", "factor(exp)4", "factor(exp)5", "factor(exp)6")) %>% 
  relabel_predictors(
    c("factor(exp)1" = "Freedoms Condition",
      "factor(exp)2" = "Too New Condition",
      "factor(exp)3" = "Trust Condition",
      "factor(exp)4" = "Moral Condition",
      "factor(exp)5" = "Pandemic Condition",
      "factor(exp)6" = "Partisanship Condition")) + 
  theme(legend.position = "bottom") + 
  theme_bw(base_size = 18) + xlab("") + ylab("") +
  ggtitle("Independents ('Requirements' Only)") + scale_x_continuous(limits = c(-1, 1)) +
  scale_colour_grey(
    name = "Outcomes",
    labels = c("Covid Vaccine", "Covid Mandate", "Childhood Vaccine", "Childhood Mandate")) + theme(legend.title=element_text(size=13), legend.position = c(0.15,0.15), legend.text=element_text(size=11), 
                                                                                                    legend.background=element_rect(linetype="solid", colour="#999999")) 
figure3ixr


##Democrats by mandate v requirement - Figure S2
figure4de <- ggarrange(figure3dxz, figure3dxr, widths=c(1,1))
figure4de
##Republicans by mandate v requirement - Figure S3
figure4re <- ggarrange(figure3rxz, figure3rxr, widths=c(1,1))
figure4re
##Independents by mandate v requirement - Figure S4
figure4in <- ggarrange(figure3ixz, figure3ixr, widths=c(1,1))
figure4in
################################################################################




################################################################################
################ Experiment by Trust - Figures S9 - S10 ####################

# Trust correlations
w23$inst_trust1_7
trustinst <- w23[, c("inst_trust1_7.0", "inst_trust1_8.0", "inst_trust1_9.0", "inst_trust2_1.0", "inst_trust2_2.0", "inst_trust2_3.0", "inst_trust2_6.0")]
trustcorr <- cor(trustinst, use = "complete.obs")
trustcorr
w23$trustind <- apply(X = w23[,c("inst_trust1_7.0", "inst_trust1_8.0", "inst_trust1_9.0", "inst_trust2_1.0", "inst_trust2_2.0", "inst_trust2_3.0", "inst_trust2_6.0")] == 2, MARGIN = 1, FUN = sum, na.rm=TRUE)

# trust index creation
w23$trustind2 <- w23$inst_trust1_7.0+w23$inst_trust1_8.0+w23$inst_trust1_9.0+w23$inst_trust2_1.0+w23$inst_trust2_2.0+w23$inst_trust2_3.0+w23$inst_trust2_6.0
trustind2 <- w23$trustind2
summary(trustind2)

# create data frames of people above and below median of 20
lowertr <- w23 %>% filter(trustind2 > 22.99)
lowertr
highertr <- w23 %>% filter(trustind2 < 16.01)
highertr

# Figures - FIGURE S9
lmt1 <- lm(cov_mand ~ factor(exp), data = lowertr)
summary(lmt1)
lmt1a <- lm(mmr_mand ~ factor(exp), data = lowertr)
summary(lmt1a)
lmt1b <- polr(cov_risk2 ~ factor(exp), data = lowertr, Hess=TRUE)
summary(lmt1b)
lmt1c <- polr(mmr_risk2 ~ factor(exp), data = lowertr, Hess=TRUE)
summary(lmt1c) 
fig6tr <- dwplot(list(lmt1, lmt1a, lmt1b, lmt1c),
                 vline = geom_vline(
                   xintercept = 0,
                   colour = "grey60",
                   linetype = 2),
                 vars_order = c("factor(exp)1", "factor(exp)2", "factor(exp)3", "factor(exp)4", "factor(exp)5", "factor(exp)6")) %>% 
  relabel_predictors(
    c("factor(exp)1" = "Freedoms Condition",
      "factor(exp)2" = "Too New Condition",
      "factor(exp)3" = "Trust Condition",
      "factor(exp)4" = "Moral Condition",
      "factor(exp)5" = "Pandemic Condition",
      "factor(exp)6" = "Partisanship Condition")) +
  theme(legend.position = "bottom") + 
  theme_bw(base_size = 14) + xlab("Coefficient Estimate") + ylab("") + scale_x_continuous(limits = c(-0.4, 0.5)) +
  ggtitle("") +
  scale_colour_grey(
    name = "",
    labels = c("Covid Vaccine", "Covid Mandate", "Childhood Vaccine", "Childhood Mandate")) + theme(legend.position = "bottom")
fig6tr

# Figures - FIGURE S10
lmt1x <- lm(cov_mand ~ factor(exp), data = highertr)
summary(lmt1x)
lmt1ax <- lm(mmr_mand ~ factor(exp), data = highertr)
summary(lmt1ax)
lmt1bx <- polr(cov_risk2 ~ factor(exp), data = highertr, Hess=TRUE)
summary(lmt1bx)
lmt1cx <- polr(mmr_risk2 ~ factor(exp), data = highertr, Hess=TRUE)
summary(lmt1cx) 
fig6trx <- dwplot(list(lmt1x, lmt1ax, lmt1bx, lmt1cx),
                  vline = geom_vline(
                    xintercept = 0,
                    colour = "grey60",
                    linetype = 2),
                  vars_order = c("factor(exp)1", "factor(exp)2", "factor(exp)3", "factor(exp)4", "factor(exp)5", "factor(exp)6")) %>% 
  relabel_predictors(
    c("factor(exp)1" = "Freedoms Condition",
      "factor(exp)2" = "Too New Condition",
      "factor(exp)3" = "Trust Condition",
      "factor(exp)4" = "Moral Condition",
      "factor(exp)5" = "Pandemic Condition",
      "factor(exp)6" = "Partisanship Condition")) +
  theme(legend.position = "bottom") + 
  theme_bw(base_size = 14) + xlab("Coefficient Estimate") + ylab("") + scale_x_continuous(limits = c(-0.4, 0.5)) +
  ggtitle("") +
  scale_colour_grey(
    name = "",
    labels = c("Covid Vaccine", "Covid Mandate", "Childhood Vaccine", "Childhood Mandate")) + theme(legend.position = "bottom")
fig6trx
################################################################################






################################################################################
################ EXperiments by Vaccine status - Figure S11 ####################
unvax <- w23 %>% filter(vaccine_get == 3)
unvax
vax <- w23 %>% filter(vaccine_get < 3)
vax

lm2u <- lm(cov_mand ~ factor(exp), data = unvax)
summary(lm2u)
lm4u <- lm(mmr_mand ~ factor(exp), data = unvax)
summary(lm4u)
lm5u <- polr(cov_risk2 ~ factor(exp), data = unvax, Hess=TRUE)
summary(lm5u)
lm6u <- polr(mmr_risk2 ~ factor(exp), data = unvax, Hess=TRUE)
summary(lm6u)
figure5un <- dwplot(list(lm5u, lm2u, lm6u, lm4u),
                    vline = geom_vline(
                      xintercept = 0,
                      colour = "grey60",
                      linetype = 2),
                    vars_order = c("factor(exp)1", "factor(exp)2", "factor(exp)3", "factor(exp)4", "factor(exp)5", "factor(exp)6")) %>% 
  relabel_predictors(
    c("factor(exp)1" = "Freedoms Condition",
      "factor(exp)2" = "Too New Condition",
      "factor(exp)3" = "Trust Condition",
      "factor(exp)4" = "Moral Condition",
      "factor(exp)5" = "Pandemic Condition",
      "factor(exp)6" = "Partisanship Condition")) +
  theme(legend.position = "bottom") + 
  theme_bw(base_size = 18) + xlab("") + ylab("") + 
  ggtitle("No COVID Vaccine Doses") +
  scale_colour_grey(
    name = "Outcomes",
    labels = c("Covid Vaccine", "Covid Mandate", "Childhood Vaccine", "Childhood Mandate")) + theme(legend.title=element_text(size=13), legend.position = c(0.17,0.15), legend.text=element_text(size=11),                                                                                                 legend.background=element_rect(linetype="solid", colour="#999999")) + 
  scale_x_continuous(limits = c(-1, 1)) 
figure5un

lm2v <- lm(cov_mand ~ factor(exp), data = vax)
summary(lm2v)
lm4v <- lm(mmr_mand ~ factor(exp), data = vax)
summary(lm4v)
lm5v <- polr(cov_risk2 ~ factor(exp), data = vax, Hess=TRUE)
summary(lm5v)
lm6v <- polr(mmr_risk2 ~ factor(exp), data = vax, Hess=TRUE)
summary(lm6v)
figurev <- dwplot(list(lm5v, lm2v, lm6v, lm4v),
                  vline = geom_vline(
                    xintercept = 0,
                    colour = "grey60",
                    linetype = 2),
                  vars_order = c("factor(exp)1", "factor(exp)2", "factor(exp)3", "factor(exp)4", "factor(exp)5", "factor(exp)6")) %>% 
  relabel_predictors(
    c("factor(exp)1" = "Freedoms Condition",
      "factor(exp)2" = "Too New Condition",
      "factor(exp)3" = "Trust Condition",
      "factor(exp)4" = "Moral Condition",
      "factor(exp)5" = "Pandemic Condition",
      "factor(exp)6" = "Partisanship Condition")) +
  theme(legend.position = "bottom") + 
  theme_bw(base_size = 18) + xlab("") + ylab("") + 
  ggtitle("One or Two COVID Vaccine Doses") +
  scale_colour_grey(
    name = "Outcomes",
    labels = c("Covid Vaccine", "Covid Mandate", "Childhood Vaccine", "Childhood Mandate")) + theme(legend.title=element_text(size=13), legend.position = c(0.17,0.15), legend.text=element_text(size=11), 
                                                                                                    legend.background=element_rect(linetype="solid", colour="#999999")) + 
  scale_x_continuous(limits = c(-1, 1)) 
figurev

##### Figure S11
figureuv <- ggarrange(figure5un, figurev, ncol=1, nrow=2, labels=c('Unvaccinated', 'Vaccinated only'))
figureuv
################################################################################




################################################################################
################ Experiment by parental status - Figure S13 ####################

pardat <- w23 %>% filter(Children == "112")
nopardat <- w23 %>% filter(Children == "111")

lm2m <- lm(cov_mand ~ factor(exp), data = pardat)
summary(lm2m)
lm4m <- lm(mmr_mand ~ factor(exp), data = pardat)
summary(lm4m)
lm5m <- glm(formula = cov_risk_bi ~ factor(exp), family = binomial(link = "logit"), 
            data = pardat)
summary(lm5m)
lm6m <- glm(formula = mmr_risk_bi ~ factor(exp), family = binomial(link = "logit"), 
            data = pardat)
summary(lm6m)

lm2r <- lm(cov_mand ~ factor(exp), data = nopardat)
summary(lm2r)
lm4r <- lm(mmr_mand ~ factor(exp), data = nopardat)
summary(lm4r)
lm5r <- glm(formula = cov_risk_bi ~ factor(exp), family = binomial(link = "logit"), 
            data = nopardat)
summary(lm5r)
lm6r <- glm(formula = mmr_risk_bi ~ factor(exp), family = binomial(link = "logit"), 
            data = nopardat)
summary(lm6r)

figure2xp <- dwplot(list(lm5m, lm2m, lm6m, lm4m),
                       vline = geom_vline(
                         xintercept = 0,
                         colour = "grey60",
                         linetype = 2),
                       vars_order = c("factor(exp)1", "factor(exp)2", "factor(exp)3", "factor(exp)4", "factor(exp)5", "factor(exp)6")) %>% 
  relabel_predictors(
    c("factor(exp)1" = "Freedoms Condition",
      "factor(exp)2" = "Too New Condition",
      "factor(exp)3" = "Trust Condition",
      "factor(exp)4" = "Moral Condition",
      "factor(exp)5" = "Pandemic Condition",
      "factor(exp)6" = "Partisanship Condition")) +
  theme(legend.position = "bottom") + 
  theme_bw(base_size = 18) + xlab("") + ylab("") + xlab("") + 
  ggtitle("Parents") +
  scale_colour_grey(
    name = "Outcomes",
    labels = c("Covid Vaccine", "Covid Mandate", "Childhood Vaccine", "Childhood Mandate")) + theme(legend.title=element_text(size=12), legend.position = c(0.85,0.15), legend.text=element_text(size=9), 
                                                                                                    legend.background=element_rect(linetype="solid", colour="#999999"))+
  scale_x_continuous(limits = c(-1, 1))
figure2xp

figure2xnp <- dwplot(list(lm5r, lm2r, lm6r, lm4r),
                      vline = geom_vline(
                        xintercept = 0,
                        colour = "grey60",
                        linetype = 2),
                      vars_order = c("factor(exp)1", "factor(exp)2", "factor(exp)3", "factor(exp)4", "factor(exp)5", "factor(exp)6")) %>% 
  relabel_predictors(
    c("factor(exp)1" = "Freedoms Condition",
      "factor(exp)2" = "Too New Condition",
      "factor(exp)3" = "Trust Condition",
      "factor(exp)4" = "Moral Condition",
      "factor(exp)5" = "Pandemic Condition",
      "factor(exp)6" = "Partisanship Condition")) +
  theme(legend.position = "bottom") + 
  theme_bw(base_size = 18) + xlab("") + ylab("") + xlab("") +
  ggtitle("Not Parents") +
  scale_colour_grey(
    name = "Outcomes",
    labels = c("Covid Vaccine", "Covid Mandate", "Childhood Vaccine", "Childhood Mandate")) +  theme(legend.title=element_text(size=12), legend.position = c(0.15,0.15), legend.text=element_text(size=9), 
                                                                                                     legend.background=element_rect(linetype="solid", colour="#999999")) +
  scale_x_continuous(limits = c(-1, 1))
figure2xnp

figure2par <- ggarrange(figure2xp, figure2xnp, ncol=1, nrow=2, labels=c('Parents', 'Non-Parents'))
figure2par
################################################################################

